package com.csxy.zqm.controller;

import com.csxy.zqm.entity.EduCourse;
import com.csxy.zqm.entity.EduTeacher;
import com.csxy.zqm.service.EduCourseService;
import com.csxy.zqm.service.EduTeacherService;
import com.csxy.zqm.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/eduservice/indexFront")
public class IndexFrontController {
    @Autowired
    private EduCourseService eduCourseService;
    @Autowired
    private EduTeacherService eduTeacherService;
    //首页查询前8条热门课程和前4条热门名师

    @GetMapping("/index")
    public R index() {
        //调用查询前8条热门课程
        List<EduCourse> courseList = eduCourseService.selectHotCourse();
        //查询前4个热门讲师
        List<EduTeacher> teacherList = eduTeacherService.selectHotTeacher();

        return R.ok().data("courseList", courseList).data("teacherList", teacherList);
    }
}
